00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00052 define("PATH_TO_ROOT", "../");
00054 require_once (PATH_TO_ROOT."common/init.inc.php");
00055 if (isset($_POST['Cancel'])) {
00056 header("Location: ".$_SERVER['PHP_SELF']);
00057 exit;
00058 }
00060 require_once (PATH_TO_ROOT."common/header.inc.php");
00061 include_once "header.inc.php";
00062 writeContentHeader("FotoForum");
00063 include_once "./classes/class.header.inc.php";
00064 if (isset($action) && $action != 'remove_link') {
00065 $action = ((isset($_POST['action'])) ? $_POST['action'] : '');
00066 }
00067 if (!isset($action) || $action == '') {
00068 if (isset($_GET['action'])) $action = $_GET['action'];
00069 else errormessage('Fehler', 'Bitte wählen Sie eine Aktion aus dem Menü aus.');
00070 }
00071 if (!isset($thread['threadid']) || !$thread['threadid']) {
00072 errormessage("Fehler", "ERROR: \$thread[threadid] not set!");
00073 }
00074
00075 if ($action == "close") {
00076 $navpath.= "Thread öffnen/schließen";
00077 $r_thread = forum_query("SELECT threadid, threadclosed, threadauthor FROM forum_thread WHERE threadid=$thread[threadid]");
00078 $thread = mysql_fetch_array($r_thread);
00079 if (($g_user['username'] == $thread['threadauthor'] && $P->has_permission(P_CLOSE)) || $P->has_permission(P_OCLOSE)) {
00080 if ($thread['threadclosed'] == 1) {
00081 forum_query("UPDATE forum_thread SET threadclosed=0 WHERE threadid=$thread[threadid]");
00082 message(" ", "Thread wurde wieder geöffnet!<br/><a href=\"".build_link("showtopic.php?thread[threadid]=$thread[threadid]") ."\" title='Zurück zum Thread'>Zurück zum Thread</a>");
00083 } else {
00084 forum_query("UPDATE forum_thread SET threadclosed=1 WHERE threadid=$thread[threadid]");
00085 message(" ", "Thread wurde geschlossen!<br/><a href=\"".build_link("showtopic.php?thread[threadid]=$thread[threadid]") ."\" title='Zurück zum Thread'>Zurück zum Thread</a>");
00086 }
00087 } else {
00088 $navpath.= "Thread öffnen/schließen";
00089 errormessage("Fehler", "Sie haben keine Berechtigung diesen Thread zu schließen.");
00090 }
00091 }
00092
00093 if ($action == "top") {
00094 $navpath.= "Thread festmachen";
00095 $r_thread = forum_query("SELECT threadid, threadtop, threadauthor FROM forum_thread WHERE threadid=$thread[threadid]");
00096 $thread = mysql_fetch_array($r_thread);
00097 if ($P->has_permission(P_TOP)) {
00098 if ($thread['threadtop'] == 1) {
00099 forum_query("UPDATE forum_thread SET threadtop=0 WHERE threadid=$thread[threadid]");
00100 message(" ", "Thread wurde gelöst!<br/><a href=\"".build_link("showtopic.php?thread[threadid]=$thread[threadid]") ."\" title='Zurück zum Thread'>Zurück zum Thread</a>");
00101 } else {
00102 forum_query("UPDATE forum_thread SET threadtop=1 WHERE threadid=$thread[threadid]");
00103 message(" ", "Thread wurde festgemacht!<br/><a href=\"".build_link("showtopic.php?thread[threadid]=$thread[threadid]") ."\" title='Zurück zum Thread'>Zurück zum Thread</a>");
00104 }
00105 } else {
00106 $navpath.= "Thread festmachen";
00107 errormessage("Fehler", "Sie haben keine Berechtigung diesen Thread festzumachen!");
00108 }
00109 }
00110 if ($action == "move") {
00111 $navpath.= "Thread verschieben";
00112 if ($P->has_permission(P_OMOVE)) {
00113 $TFrame = new Template("./templates/frame.html");
00114 $TMoveform = new Template("./templates/movethreadform.html");
00115 $boards = array();
00116 $r_board = forum_query("SELECT boardid, boardname, categoryid FROM forum_board WHERE is_photogallery=1 ORDER BY boardorder");
00117 while ($board = mysql_fetch_array($r_board)) {
00118 $boards["$board[categoryid]"][] = "<option value=\"$board[boardid]\">-- $board[boardname]</option>";
00119 }
00120 $MOVEOPTIONS = '';
00121 $r_category = forum_query("SELECT categoryid, categoryname FROM forum_category ORDER BY categoryorder");
00122 while ($category = mysql_fetch_array($r_category)) {
00123 $MOVEOPTIONS.= "<option value=\"0\">$category[categoryname]</options>";
00124 while (list($k, $v) = @each($boards["$category[categoryid]"])) {
00125 $MOVEOPTIONS.= "$v";
00126 }
00127 }
00128 eval($TMoveform->GetTemplate("CONTENT"));
00129 eval($TFrame->GetTemplate());
00130 } else {
00131 $navpath.= "Thread verschieben";
00132 errormessage("Fehler", "Sie haben keine Berechtigung diesen Thread zu verschieben.");
00133 }
00134 }
00135 if ($action == "do_move") {
00136 if ($P->has_permission(P_OMOVE)) {
00137 if (!$into || $into == 0) {
00138 $navpath.= "Thread verschieben";
00139 message(" ", "Bitte wählen Sie ein Forum aus!");
00140 }
00141 $r_thread = forum_query("SELECT threadid, threadtime, threadtopic, threadauthor, threadlastreplyby, boardid, threadreplies FROM forum_thread WHERE threadid=$thread[threadid]");
00142 $thread = mysql_fetch_array($r_thread);
00143 $thread['threadreplies']++;
00144
00145 if ($createlink != 1) {
00146 forum_query("UPDATE forum_board SET boardthreads=boardthreads-1, boardposts=boardposts-$thread[threadreplies] WHERE boardid=$thread[boardid]");
00147 }
00148 global $db, $EZSQL_ERROR;
00149 $fileList = $db->get_results("SELECT postfilesavename FROM forum_post WHERE postfilesize > 0 AND threadid = $thread[threadid]");
00150
00151 $r_courseID = forum_query("SELECT forum_category.categoryid AS categoryID FROM forum_category LEFT JOIN forum_board ON
00152 (forum_board.categoryid = forum_category.categoryid) LEFT JOIN forum_thread ON (forum_thread.boardid = forum_board.boardid)
00153 WHERE forum_thread.threadid=$thread[threadid] AND forum_board.is_photogallery=1");
00154 $courseIDRow = mysql_fetch_array($r_courseID);
00155 $courseID = $courseIDRow['categoryID'];
00156
00157 forum_query("UPDATE forum_board SET boardthreads=boardthreads+1, boardposts=boardposts+$thread[threadreplies] WHERE boardid='".intval($into) ."'");
00158 forum_query("UPDATE forum_thread SET boardid=".intval($into) ." WHERE threadid=$thread[threadid]");
00159 if (isset($createlink) && $createlink == 1) {
00160
00161 forum_query("INSERT INTO
00162 forum_thread (threadtopic, threadtime, threadauthor, boardid, threadlastreplyby, threadlink, threadclosed)
00163 VALUES (
00164 '".addslashes($thread['threadtopic']) ."',
00165 '$thread[threadtime]',
00166 '".addslashes($thread['threadauthor']) ."',
00167 '$thread[boardid]',
00168 '".addslashes($thread['threadlastreplyby']) ."',
00169 '$thread[threadid]',
00170 '1')");
00171 }
00172
00173 updateboard($thread['boardid']);
00174 updateboard($into);
00175
00176 $r_newCourseID = forum_query("SELECT forum_category.categoryid AS categoryID FROM forum_category LEFT JOIN forum_board ON
00177 (forum_board.categoryid = forum_category.categoryid) WHERE forum_board.boardid=$into AND forum_board.is_photogallery=1");
00178 $newCourseIDRow = mysql_fetch_array($r_newCourseID);
00179 $newCourseID = $newCourseIDRow['categoryID'];
00180
00181
00182 $uploaddir = PATH_TO_ROOT.$settings["upload_path"]."forum/course/".$newCourseID."/board/".$into;
00183 Utilities::mkdir_r($uploaddir);
00184
00185
00186
00187 $oldDir = PATH_TO_ROOT.$settings["upload_path"]."forum/course/".$courseID."/board/".$thread['boardid'];
00188 $dir = @opendir($oldDir) or die("Ungültiges Verzeichnis.");
00189 if (isset($fileList)) {
00190 foreach($fileList as $fileName) {
00191 if ((!@file_exists($uploaddir.'/'.$fileName->postfilesavename)) && @rename($oldDir.'/'.$fileName->postfilesavename, $uploaddir.'/'.$fileName->postfilesavename)) {
00192
00193
00194 } else {
00195
00196
00197 }
00198 }
00199 }
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210 message_redirect("Aktion wird ausgeführt", "board.php?board[boardid]=$thread[boardid]");
00211 } else {
00212 $navpath.= "Thread verschieben";
00213 errormessage("Fehler", "Sie haben keine Berechtigung diesen Thread zu verschieben.");
00214 }
00215 }
00216
00217 if ($action == "delete") {
00218 $r_thread = forum_query("SELECT threadid, threadauthor FROM forum_thread WHERE threadid=$thread[threadid]");
00219 $thread = mysql_fetch_array($r_thread);
00220 if (($g_user['username'] == $thread['threadauthor'] && $P->has_permission(P_DELTHREAD)) || $P->has_permission(P_ODELTHREAD)) {
00221 $navpath.= "Thread löschen";
00222 errormessage(" ", 'Soll dieser Thread wirklich GELÖSCHT werden?<br/>
00223 <form name="theform" method="post" action="'.build_link("threadops.php") .'">
00224 <p class="pForm"><input type="hidden" name="action" value="do_delete"/></p>
00225 <p class="pForm"><input type="hidden" name="thread[threadid]" value="'.$thread['threadid'].'"/></p>
00226 <p class="pForm"><input class="tbbutton" type="submit" name="Submit" value="Löschen >>"/></p>
00227 </form>');
00228 } else {
00229 $navpath.= "Thread löschen";
00230 errormessage("Fehler", "Sie haben keine Berechtigung diesen Thread zu löschen.");
00231 }
00232 }
00233
00234 if ($action == "do_delete") {
00235 $r_thread = forum_query("SELECT threadid, threadreplies, threadauthor, boardid FROM forum_thread WHERE threadid=$thread[threadid]");
00236 $thread = mysql_fetch_array($r_thread);
00237 if (($g_user['username'] == $thread['threadauthor'] && $P->has_permission(P_DELTHREAD)) || $P->has_permission(P_ODELTHREAD)) {
00238 $thread['threadreplies']++;
00239
00240 forum_query("UPDATE forum_board SET boardposts=boardposts-$thread[threadreplies], boardthreads=boardthreads-1 WHERE boardid=$board[boardid] AND is_photogallery=1");
00241
00242 forum_query("DELETE FROM forum_thread WHERE threadid=$thread[threadid] OR threadlink=$thread[threadid]");
00243
00244 forum_query("DELETE FROM forum_subscribe WHERE threadid=$thread[threadid]");
00245
00246 $postIDs = $db->get_col("SELECT postid FROM forum_post WHERE threadid='{$thread['threadid']}'");
00247 RoleArtefacts::deleteItem(FORUM, $postIDs);
00248 TeamArtefacts::deleteItem(FORUM, $postIDs);
00249
00250 forum_query("DELETE FROM photogallery_picquote WHERE threadid=$thread[threadid]");
00251
00252
00253
00254
00255 $r_file = forum_query("SELECT
00256 post.postfilename, post.postfilesavename
00257 FROM
00258 forum_post as post
00259 WHERE
00260 threadid = $thread[threadid]");
00261 $file = mysql_fetch_array($r_file);
00262
00263 forum_query("DELETE FROM forum_post WHERE threadid=$thread[threadid]");
00264
00265 $courseID = $_SESSION['course'];
00266 $boardID = $board['boardid'];
00267 $uploaddir = "../upload/forum/course/".$courseID."/board/".$boardID."/";
00268 if (is_file($uploaddir.$file['postfilesavename']) && !(@unlink($uploaddir.$file['postfilesavename']))) {
00269 errormessage("Fehler beim Löschen der Datei!", "Fehler beim Löschen der Datei.<br/><a href=\"".build_link("showtopic.php?thread[threadid]=$thread[threadid]") ."\">Zurück zum Thread</a>");
00270 }
00271
00272 updateboard($thread['boardid']);
00273 $navpath.= "Thread löschen";
00274 message(" ", "Thread wurde gelöscht!<br/><a href=\"".build_link("board.php?board[boardid]=$board[boardid]") ."\">Zurück zum Board</a>");
00275 } else {
00276 $navpath.= "Thread löschen";
00277 errormessage("Fehler", "Sie haben keine Berechtigung diesen Thread zu löschen.");
00278 }
00279 }
00280
00281 if ($action == 'remove_link') {
00282 errormessage(" ", 'Soll dieser Thread-Link wirklich entfernt werden?<br/>
00283 <form name="theform" method="post" action="'.build_link('threadops.php') .'">
00284 <p class="pForm"><input type="hidden" name="action" value="do_remove_link"/></p>
00285 <p class="pForm"><input type="hidden" name="thread[threadid]" value="'.$thread['threadid'].'"/></p>
00286 <p class="pForm"><input class="tbbutton" type="submit" name="Submit" value="Link entfernen >>"/></p>
00287 </form>');
00288 }
00289
00290
00291
00292
00293
00294 if ($action == 'do_remove_link') {
00295 if ($P->has_permission(P_OMOVE)) {
00296 $r_thread = forum_query("SELECT threadid, boardid FROM forum_thread WHERE threadid=$thread[threadid]");
00297 $thread = mysql_fetch_array($r_thread);
00298 forum_query("DELETE FROM forum_thread WHERE threadid=$thread[threadid]");
00299 updateboard($thread['boardid']);
00300 message('Info', 'Der Thread-Link wurde erfolgreich entfernt.<br/><a href="'.build_link('board.php?board[boardid]='.$board['boardid']) .'" title="Zurück zum Board">Zurück zum Board</a>');
00301 } else {
00302 errormessage('Fehler', 'Sie haben keine Berechtigung, diesen Thread-Link zu entfernen');
00303 }
00304 }
00305
00306
00307 if ($action == 'positiv') {
00308 $r_thread = forum_query("SELECT threadid, boardid, userID FROM forum_thread WHERE threadid=$thread[threadid]");
00309 $thread = mysql_fetch_array($r_thread);
00310
00311 if (intval($_SESSION['userid']) == $thread['userID'] || $_SESSION['usergroup'] == 1 || $_SESSION['usergroup'] == 3 || $_SESSION['usergroup'] == 4) {
00312 forum_query('UPDATE forum_thread SET acklevel = 0, ackpost = '.$post[postid].' WHERE threadid = '.$thread[threadid]);
00313 message_redirect("Antwort wurde bewertet", "showtopic.php?thread[threadid]=$thread[threadid]");
00314 } else {
00315 errormessage('Sie haben keine Berechtigung diese Nachricht zu bewerten.');
00316 }
00317 }
00318 if ($action == 'neutral') {
00319 $r_thread = forum_query("SELECT threadid, boardid, userID FROM forum_thread WHERE threadid=$thread[threadid]");
00320 $thread = mysql_fetch_array($r_thread);
00321
00322 if (intval($_SESSION['userid']) == $thread['userID'] || $_SESSION['usergroup'] == 1 || $_SESSION['usergroup'] == 3 || $_SESSION['usergroup'] == 4) {
00323 forum_query('UPDATE forum_thread SET acklevel = 1, ackpost = '.$post[postid].' WHERE threadid = '.$thread[threadid]);
00324 message_redirect("Antwort wurde bewertet", "showtopic.php?thread[threadid]=$thread[threadid]");
00325 } else {
00326 errormessage('Sie haben keine Berechtigung diese Nachricht zu bewerten.');
00327 }
00328 }
00329 if ($action == 'negativ') {
00330 $r_thread = forum_query("SELECT threadid, boardid, userID FROM forum_thread WHERE threadid=$thread[threadid]");
00331 $thread = mysql_fetch_array($r_thread);
00332
00333 if (intval($_SESSION['userid']) == $thread['userID'] || $_SESSION['usergroup'] == 1 || $_SESSION['usergroup'] == 3 || $_SESSION['usergroup'] == 4) {
00334 forum_query('UPDATE forum_thread SET acklevel = 2, ackpost = '.$post[postid].' WHERE threadid = '.$thread[threadid]);
00335 message_redirect("Antwort wurde bewertet", "showtopic.php?thread[threadid]=$thread[threadid]");
00336 } else {
00337 errormessage('Sie haben keine Berechtigung diese Nachricht zu bewerten.');
00338 }
00339 }
00340 include_once "footer.inc.php";
00342 require_once (PATH_TO_ROOT."common/footer.inc.php");
00343 ?>